using System;
using System.Runtime.CompilerServices;
using jQueryApi;
using SyncJS;

namespace SyncJs
{
    [IgnoreNamespace]
    [GlobalMethods]
    public static class Main
    {
        [PreserveCase]
        public static void Start()
        {
            Script.Literal("window.external.GetSyncInfo()");
            SyncList.ClearLists();
            jQuery.Select("#SyncUpMsg").Html("Loading ...");
            SyncList.InitLists();
        }

        [PreserveCase]
        public static string InfoList()
        {
            return SyncList.InfoList;
        }

        [PreserveCase]
        public static void ShowList(string jsonResult)
        {
            SyncInfoJS[] syncInfosJs = (SyncInfoJS[]) Script.Eval("(" + jsonResult + ")");

            jQuery.Select("#SyncUpMsg").Empty();
            SyncList.FillLists(syncInfosJs);
        }

        [PreserveCase]
        public static void ShowError(string errorMsg)
        {
            jQuery.Select("#SyncUpMsg").Text(errorMsg);
        }
    }
}